export const buildTree = (array: any, parentId: string) => {
  const tree = []
  for (const item of array) {
    if (item.parentId === parentId) {
      const children = buildTree(array, item.id)
      if (children.length) {
        item.children = children
      }
      tree.push(item)
    }
  }
  return tree
}
export const buildTreeNum = (tree: any) => {

  // 处理当前节点
  // console.log(tree,'adfasfasdf')
  for (let i = 0; i < tree.length; i++) {
    if (tree[i].children) {
      tree[i].name += ` (${tree[i].children.length})`;
    }
    // 递归遍历子节点
    if (tree[i].children && tree[i].children.length > 0) {
      buildTreeNum(tree[i].children);
    }
  }


  return tree
}
